import { AcceptLanguageResolver, HeaderResolver, I18nModule, QueryResolver } from 'nestjs-i18n'
import * as path from 'path'
import { AppFlowModule } from '@apps/flow/app-flow.module'
import { AppMetaModule } from '@apps/meta/app-meta.module'
import { I18nFileJsonLoader } from '@libs/lhy-common'
import { LhyCoreModule } from '@libs/lhy-core'
import { Module } from '@nestjs/common'
import { AppConfig } from './config/entity/app-config.entity'

@Module({
  imports: [
    I18nModule.forRoot({
      fallbackLanguage: 'zh-cn',
      loaderOptions: {
        path: path.join(__dirname, '../resource/i18n/locale'),
        watch: true,
      },
      resolvers: [{ use: QueryResolver, options: ['lang'] }, AcceptLanguageResolver, HeaderResolver],
      loader: I18nFileJsonLoader,
    }),
    LhyCoreModule.forRoot({
      config: {
        config: AppConfig,
      },
    }),

    AppMetaModule,
    AppFlowModule,
  ],
})
export class AppModule {}
